﻿<phone:PhoneApplicationPage 
    x:Class="DDU.Curriculum.Views.CourseEditView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:UX="clr-namespace:DDU.UX;assembly=DDU.UX"
    xmlns:viewmodel="clr-namespace:DDU.ViewModel;assembly=DDU.ViewModel"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:Converters="clr-namespace:DDU.Converters;assembly=DDU.Converters"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    mc:Ignorable="d" d:DesignHeight="800" d:DesignWidth="480"
    shell:SystemTray.IsVisible="False">

    <phone:PhoneApplicationPage.Resources>
        <Converters:EnumTranslateConverter x:Key="EnumTranslateConverter"/>
        <Converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
    </phone:PhoneApplicationPage.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.DataContext>
            <viewmodel:CourseEditViewModel/>
        </Grid.DataContext>
        <Grid.Background>
            <ImageBrush Stretch="Fill" ImageSource="/Assets/back.png"/>
        </Grid.Background>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock Text="{StaticResource IDS_APP_NAME}" Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock Text="编辑课程" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition Width="auto"/>
            </Grid.ColumnDefinitions>
            <ScrollViewer>
                <StackPanel>
                    <toolkit:ListPicker Header="学期" ItemsSource="{Binding ItemsOfSemesters}" SelectedItem="{Binding SelectedSemester,Mode=TwoWay}" ExpansionMode="FullScreenOnly">
                        <toolkit:ListPicker.ItemTemplate>
                            <DataTemplate>
                                <TextBlock >
                                    <Run Text="{Binding EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Grade, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Term, Converter={StaticResource EnumTranslateConverter}}"/>
                                </TextBlock>
                            </DataTemplate>
                        </toolkit:ListPicker.ItemTemplate>
                        <toolkit:ListPicker.FullModeItemTemplate>
                            <DataTemplate>
                                <TextBlock Style="{StaticResource PhoneTextTitle2Style}" Margin="0,12">
                                    <Run Text="{Binding EducationLevel, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Grade, Converter={StaticResource EnumTranslateConverter}}"/>
                                    <Run Text=" "/>
                                    <Run Text="{Binding Term, Converter={StaticResource EnumTranslateConverter}}"/>
                                </TextBlock>
                            </DataTemplate>
                        </toolkit:ListPicker.FullModeItemTemplate>
                    </toolkit:ListPicker>
                    <StackPanel Visibility="{Binding CanAdd, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}">
                        <toolkit:ListPicker Header="上课时间" ItemsSource="{Binding EnumsOfDays}" SelectedItem="{Binding CurrentSchedule.DayOfWeek,Mode=TwoWay}">
                            <toolkit:ListPicker.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding Converter={StaticResource EnumTranslateConverter}}"/>
                                </DataTemplate>
                            </toolkit:ListPicker.ItemTemplate>
                            <toolkit:ListPicker.FullModeItemTemplate>
                                <DataTemplate>
                                    <TextBlock Margin="0,12" Text="{Binding Converter={StaticResource EnumTranslateConverter}}" Style="{StaticResource PhoneTextTitle2Style}"/>
                                </DataTemplate>
                            </toolkit:ListPicker.FullModeItemTemplate>
                        </toolkit:ListPicker>

                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="课程名称"/>
                        <TextBox Text="{Binding CurrentSchedule.Name, Mode=TwoWay}"/>

                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="任课老师"/>
                        <TextBox Text="{Binding CurrentSchedule.Teacher, Mode=TwoWay}"/>

                        <TextBlock Style="{StaticResource PhoneTextSubtleStyle}" Text="教学地点"/>
                        <TextBox Text="{Binding CurrentSchedule.RoomOrPlace, Mode=TwoWay}"/>

                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>
                            <toolkit:TimePicker Header="开始时间" Value="{Binding CurrentSchedule.StartTime, Mode=TwoWay}"/>
                            <toolkit:TimePicker Header="结束时间" Value="{Binding CurrentSchedule.EndTime,Mode=TwoWay}" Grid.Column="1"/>
                        </Grid>

                        <CheckBox Content="常规课程" IsChecked="{Binding CurrentSchedule.RoutineCourse, Mode=TwoWay}"/>
                    </StackPanel>
                </StackPanel>
            </ScrollViewer>

            <StackPanel Grid.Column="1" VerticalAlignment="Bottom">
                <UX:UXPathButton IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_SUBMIT}}" Command="{Binding UpdateCommand, Mode=OneWay}" Margin="0,12"/>
                <UX:UXPathButton IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_DELETE}}" Command="{Binding DeleteCommand, Mode=OneWay}" />
                <UX:UXPathButton IconPath="{Binding Mode=OneWay, Source={StaticResource PATH_ICON_CLOSE}}" Command="{Binding CancelCommand, Mode=OneWay}" Padding="13" Margin="0,12"/>
            </StackPanel>
        </Grid>

    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <!--<phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
                <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>-->

</phone:PhoneApplicationPage>
